package cn.edu.zxj.ojspring.mapper;

import cn.edu.zxj.ojspring.model.info.OJInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description：实现增删改查操作
 *
 * @author: zxj
 * @date: 2024-02-20
 * @time: 20:48:17
 */
@Mapper
public interface OJMapper {
    /**
     * @description: 查询所有的题目
     **/
    @Select("select id,title,level from oj_table where delete_flag = 0")
    List<OJInfo> selectAllOJ();

    /**
     * @description: 依据 ID 查询题目
     **/
    @Select("select id,title,level,description,template_code,test_code from oj_table where delete_flag = 0 and id = #{id}")
    OJInfo selectOJBy(Integer id);

    /**
     * @description: 插入题目信息
     **/
    @Insert("insert into oj_table (title, level, description, template_code, test_code) values (#{title},#{level},#{description},#{templateCode},#{testCode})")
    Integer insert(OJInfo ojInfo);

    /**
     * @description: 逻辑删除题目
     **/
    @Update("update oj_table set delete_flag = 1 where id = #{id}")
    Integer delete(Integer id);
}
